<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Linux," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;linux有自己一套完整的启动体系，抓住了linux启动的脉络，linux的启动过程将不再神秘。 &amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;本文中假设inittab中设置的init tree为：  /etc/rc.d/rc0.d /etc/rc.d/">
<meta name="keywords" content="Linux">
<meta property="og:type" content="article">
<meta property="og:title" content="rc.local自启动学习">
<meta property="og:url" content="https://hcldirgit.github.io/2017/09/03/1. Linux 基础/63. rc.local自启动学习/index.html">
<meta property="og:site_name" content="失落的乐章">
<meta property="og:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;linux有自己一套完整的启动体系，抓住了linux启动的脉络，linux的启动过程将不再神秘。 &amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;本文中假设inittab中设置的init tree为：  /etc/rc.d/rc0.d /etc/rc.d/">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2017-09-01T08:31:27.492Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="rc.local自启动学习">
<meta name="twitter:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;linux有自己一套完整的启动体系，抓住了linux启动的脉络，linux的启动过程将不再神秘。 &amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;本文中假设inittab中设置的init tree为：  /etc/rc.d/rc0.d /etc/rc.d/">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://hcldirgit.github.io/2017/09/03/1. Linux 基础/63. rc.local自启动学习/"/>





  <title>rc.local自启动学习 | 失落的乐章</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', '85*****1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?87980c**************99ec5e26fb5";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>











  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">失落的乐章</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">技术面前，永远都是学生。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-message">
          <a href="/message" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-external-link"></i> <br />
            
            留言
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://hcldirgit.github.io/2017/09/03/1. Linux 基础/63. rc.local自启动学习/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="失落的乐章">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/0.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="失落的乐章">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">rc.local自启动学习</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-09-03T01:55:11+08:00">
                2017-09-03
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;linux有自己一套完整的启动体系，抓住了linux启动的脉络，linux的启动过程将不再神秘。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;本文中假设inittab中设置的init tree为：</p>
<ul>
<li>/etc/rc.d/rc0.d</li>
<li>/etc/rc.d/rc1.d</li>
<li>/etc/rc.d/rc2.d</li>
<li>/etc/rc.d/rc3.d</li>
<li>/etc/rc.d/rc4.d</li>
<li>/etc/rc.d/rc5.d</li>
<li>/etc/rc.d/rc6.d</li>
<li>/etc/rc.d/init.d</li>
</ul>
<h2 id="1-关于linux的启动"><a href="#1-关于linux的启动" class="headerlink" title="1. 关于linux的启动"></a>1. 关于linux的启动</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;init是所有进程的顶层</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;init读取/etc/inittab，执行rc.sysinit脚本(注意文件名是不一定的,有些unix甚至会将语句直接写在inittab中)</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;rc.sysinit脚本作了很多工作:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">init <span class="variable">$PATH</span></div><div class="line">config network</div><div class="line">start swap <span class="keyword">function</span></div><div class="line"><span class="built_in">set</span> hostname</div><div class="line">check root file system, repair <span class="keyword">if</span> needed</div><div class="line">check root space</div><div class="line">....</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;rc.sysinit根据inittab执行rc?.d脚本</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;linux是多用户系统，getty是多用户与单用户的分水岭</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在getty之前运行的是系统脚本</p>
<h2 id="2-关于rc-d"><a href="#2-关于rc-d" class="headerlink" title="2. 关于rc.d"></a>2. 关于rc.d</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;所有启动脚本放置在 /etc/rc.d/init.d下</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;rc?.d中放置的是init.d中脚本的链接，命名格式是:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">S&#123;number&#125;&#123;name&#125;</div><div class="line">K&#123;number&#125;&#123;name&#125;</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;S开始的文件向脚本传递start参数</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;K开始的文件向脚本传递stop参数</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;number决定执行的顺序</p>
<h2 id="3-启动脚本示例"><a href="#3-启动脚本示例" class="headerlink" title="3. 启动脚本示例"></a>3. 启动脚本示例</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;这是一个用来启动httpd的 /etc/rc.d/init.d/apache 脚本：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="meta">#!/bin/bash</span></div><div class="line">......</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;可以看出他接受start,stop,restart,status参数</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;然后可以这样建立rc?.d的链接：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">cd</span> /etc/rc.d/init.d &amp;&amp;</div><div class="line">ln -sf ../init.d/apache ../rc0.d/K28apache &amp;&amp;</div><div class="line">ln -sf ../init.d/apache ../rc1.d/K28apache &amp;&amp;</div><div class="line">ln -sf ../init.d/apache ../rc2.d/K28apache &amp;&amp;</div><div class="line">ln -sf ../init.d/apache ../rc3.d/S32apache &amp;&amp;</div><div class="line">ln -sf ../init.d/apache ../rc4.d/S32apache &amp;&amp;</div><div class="line">ln -sf ../init.d/apache ../rc5.d/S32apache &amp;&amp;</div><div class="line">ln -sf ../init.d/apache ../rc6.d/K28apache</div></pre></td></tr></table></figure>
<h2 id="4-关于rc-local"><a href="#4-关于rc-local" class="headerlink" title="4. 关于rc.local"></a>4. 关于rc.local</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;经常使用的 rc.local 则完全是习惯问题，不是标准。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;各个发行版有不同的实现方法，可以这样实现：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">touch /etc/rc.d/rc.local</div><div class="line">chmod +x /etc/rc.d/rc.local</div><div class="line">ln -sf /etc/rc.d/rc.local /etc/rc.d/rc1.d/S999rc.local &amp;&amp;</div><div class="line">ln -sf /etc/rc.d/rc.local /etc/rc.d/rc2.d/S999rc.local &amp;&amp;</div><div class="line">ln -sf /etc/rc.d/rc.local /etc/rc.d/rc3.d/S999rc.local &amp;&amp;</div><div class="line">ln -sf /etc/rc.d/rc.local /etc/rc.d/rc4.d/S999rc.local &amp;&amp;</div><div class="line">ln -sf /etc/rc.d/rc.local /etc/rc.d/rc5.d/S999rc.local &amp;&amp;</div><div class="line">ln -sf /etc/rc.d/rc.local /etc/rc.d/rc6.d/S999rc.local</div></pre></td></tr></table></figure>
<h2 id="5-关于bash启动脚本"><a href="#5-关于bash启动脚本" class="headerlink" title="5. 关于bash启动脚本"></a>5. 关于bash启动脚本</h2><ul>
<li>/etc/profile</li>
<li>/etc/bashrc</li>
<li>~/.bash_profile</li>
<li>~/.bashrc</li>
</ul>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;是bash的启动脚本</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;一般用来设置单用户的启动环境，也可以实现开机单用户的程序，但要明确他们都是属于bash范畴而不是系统范畴。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;它们的具体作用介绍如下：</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;/bin/bash这个命令解释程序(后面简称shell)使用了一系列启动文件来建立一个运行环境：</p>
<ul>
<li>/etc/profile</li>
<li>/etc/bashrc</li>
<li>~/.bash_profile</li>
<li>~/.bashrc</li>
<li>~/.bash_logout</li>
</ul>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;每一个文件都有特殊的功用并对登陆和交互环境有不同的影响。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;/etc/profile 和 ~/.bash_profile 是在启动一个交互登陆shell的时候被调用。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;/etc/bashrc 和 ~/.bashrc 是在一个交互的非登陆shell启动的时候被调用。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;~/.bash_logout 在用户注销登陆的时候被读取</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;一个交互的登陆shell会在 /bin/login 成功登陆之后运行。一个交互的非登陆shell是通过命令行来运行的，如[prompt]$/bin/bash。一般一个非交互的shell出现在运行 shell脚本的时候。之所以叫非交互的shell，是因为它不在命令行上等待输入而只是执行脚本程序。</p>
<h2 id="6-关于开机程序的自动启动"><a href="#6-关于开机程序的自动启动" class="headerlink" title="6. 关于开机程序的自动启动"></a>6. 关于开机程序的自动启动</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;系统脚本可以放置在/etc/rc.d/init.d中并建立/etc/rc.d/rc?.d链接，也可以直接放置在/etc/rc.d/rc.local中。</p>
<hr>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;init.d脚本包含完整的start,stop,status,reload等参数，是标准做法，推荐使用。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;为特定用户使用的程序（如有的用户需要使用中文输入法而有的不需要）放置在~/中的bash启动脚本中。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;设置系统自动启动<br>在/etc/init.d/下创建smsafe文件<br>内容：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line"><span class="meta">#!/bin/bash</span></div><div class="line"><span class="comment"># chkconfig: 35 95 1</span></div><div class="line"><span class="comment"># description: script to start/stop smsafe</span></div><div class="line"><span class="keyword">case</span> 1instart)sh/opt/startsms.sh;;stop)sh/opt/stopsms.sh;;∗)<span class="built_in">echo</span><span class="string">"Usage: 0 (start|stop)"</span></div><div class="line">;;</div><div class="line"><span class="keyword">esac</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;更改权限</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># chmod 775 smsafe</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;加入自动启动</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># chkconfig –add smsafe</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;查看自动启动设置</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># chkconfig –list smsafe</span></div><div class="line">smsafe 0:off 1:off 2:off 3:on 4:off 5:on 6:off</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;以后可以用以下命令启动和停止脚本</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># service smsafe start 启动</span></div><div class="line"><span class="comment"># service smsafe stop 停止</span></div></pre></td></tr></table></figure>
<hr>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;jira 的启动主要依靠的是bin目录下的catalina.sh脚本，提供了如init脚本的start，stop等参数</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="meta">#!/bin/bash</span></div><div class="line"><span class="comment">#</span></div><div class="line"><span class="comment"># chkconfig: 2345 85 15</span></div><div class="line"><span class="comment"># description: jira</span></div><div class="line"><span class="comment"># processname: jira</span></div><div class="line"><span class="comment"># source function library</span></div><div class="line">. /etc/init.d/<span class="built_in">functions</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;下面一行比较重要，为jira的安装路径，没有的话，将会提示找不到文件</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div></pre></td><td class="code"><pre><div class="line">CATALINA_HOME=<span class="string">"/var/www/jira"</span></div><div class="line">RETVAL=0</div><div class="line"><span class="function"><span class="title">start</span></span>() &#123;</div><div class="line"><span class="built_in">echo</span> -n $<span class="string">"Starting jira services: "</span></div><div class="line">. /var/www/jira/bin/catalina.sh start</div><div class="line">RETVAL=$?</div><div class="line"><span class="built_in">echo</span></div><div class="line">&#125;</div><div class="line"><span class="function"><span class="title">stop</span></span>() &#123;</div><div class="line"><span class="built_in">echo</span> -n $<span class="string">"Shutting down jira services: "</span></div><div class="line">. /var/www/jira/bin/catalina.sh stop</div><div class="line">RETVAL=$?</div><div class="line"><span class="built_in">echo</span></div><div class="line">&#125;</div><div class="line"><span class="keyword">case</span> <span class="string">"<span class="variable">$1</span>"</span> <span class="keyword">in</span></div><div class="line">start)</div><div class="line">start</div><div class="line">;;</div><div class="line">stop)</div><div class="line">stop</div><div class="line">;;</div><div class="line">restart|reload)</div><div class="line">stop</div><div class="line">start</div><div class="line">;;</div><div class="line">status)</div><div class="line">status jira</div><div class="line">RETVAL=$?</div><div class="line">;;</div><div class="line">*)</div><div class="line"><span class="built_in">echo</span> <span class="string">"Usage: 0 &#123;start|stop|restart|status&#125;"</span></div><div class="line"><span class="built_in">exit</span> 1</div><div class="line"><span class="keyword">esac</span></div><div class="line"><span class="built_in">exit</span> <span class="variable">$RETVAL</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;保存为/etc/init.d/jira<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;然后利用</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">chkconfig --add jira</div><div class="line">OK</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;启动</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">/etc/init.d/jira start</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;停止</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">/etc/init.d/jira stop</div></pre></td></tr></table></figure>
<hr>
<h3 id="以Websphere为例子"><a href="#以Websphere为例子" class="headerlink" title="以Websphere为例子"></a>以Websphere为例子</h3><ol>
<li>在/etc/rc.d/init.d目录下新建启动脚本startWebsphere，键入以下内容：</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="meta">#!/bin/sh</span></div><div class="line">/opt/WebSphere/AppServer/bin/startServer.sh server1</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;修改该文件的权限：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">chmod 755 startWebsphere</div></pre></td></tr></table></figure>
<ol>
<li>在对应的目录下建立软连接(假设系统默认进入X11)</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">cd</span> /etc/rc.d/rc5.d</div><div class="line">ln -s ../init.d/startWebsphere S99startWebsphere</div></pre></td></tr></table></figure>
<ol>
<li>重启系统即可</li>
</ol>
<hr>
<h3 id="linux下oracle的自启动脚本"><a href="#linux下oracle的自启动脚本" class="headerlink" title="linux下oracle的自启动脚本"></a>linux下oracle的自启动脚本</h3><ol>
<li>写一个StartOracle.sql,假设放在/目录下</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">vi /StartOracle.sql  <span class="comment">##加入如下两行保存</span></div><div class="line">startup</div><div class="line"><span class="built_in">exit</span></div></pre></td></tr></table></figure>
<p>2.配置/etc/rc.local</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">vi /etc/rc.local   <span class="comment">##加入如下内容，保存</span></div><div class="line">su - oracle -c <span class="string">'ORACLE H OME/bin/lsnrctlstart ′ su−oracle−c ′ ORACLE_HOME/bin/sqlplus "/as sysdba" @/StartOracle.sql'</span></div></pre></td></tr></table></figure>
<ol>
<li>如果还要自动启动oracle enterprise manager(em)和isqlplus可以如下配置</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">vi /etc/rc.local     <span class="comment">##加入</span></div><div class="line">su - oracle -c <span class="string">'ORACLE H OME/bin/emctlstartdbconsole ′ su−oracle−c ′ ORACLE_HOME/bin/isqlplusctl start'</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;要知道em和isqlplus等使用的端口可以查询文件：</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$ORACLE_HOME/install/portlist.ini(以oracle 10.1.0.3为例)</p>
<hr>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Linux/" rel="tag"># Linux</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/09/03/1. Linux 基础/46.Linux支持中文/" rel="next" title="Linux支持中文">
                <i class="fa fa-chevron-left"></i> Linux支持中文
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/09/03/1. Linux 基础/21. Linux 系统下查看raid信息，以及磁盘信息/" rel="prev" title="Linux 系统下查看raid信息，以及磁盘信息">
                Linux 系统下查看raid信息，以及磁盘信息 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/0.png"
               alt="失落的乐章" />
          <p class="site-author-name" itemprop="name">失落的乐章</p>
           
              <p class="site-description motion-element" itemprop="description">失落的乐章的Blog</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/">
                <span class="site-state-item-count">627</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">38</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/hcldirgit" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-关于linux的启动"><span class="nav-number">1.</span> <span class="nav-text">1. 关于linux的启动</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-关于rc-d"><span class="nav-number">2.</span> <span class="nav-text">2. 关于rc.d</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-启动脚本示例"><span class="nav-number">3.</span> <span class="nav-text">3. 启动脚本示例</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-关于rc-local"><span class="nav-number">4.</span> <span class="nav-text">4. 关于rc.local</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-关于bash启动脚本"><span class="nav-number">5.</span> <span class="nav-text">5. 关于bash启动脚本</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-关于开机程序的自动启动"><span class="nav-number">6.</span> <span class="nav-text">6. 关于开机程序的自动启动</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#以Websphere为例子"><span class="nav-number">6.1.</span> <span class="nav-text">以Websphere为例子</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#linux下oracle的自启动脚本"><span class="nav-number">6.2.</span> <span class="nav-text">linux下oracle的自启动脚本</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">失落的乐章</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
